<?php
$item_name = strlen($dcommittee['Committee']['item_name'])>2 ? $dcommittee['Committee']['item_name'] : 'Project';
if(isset($javascript)):
    // load script in <head> section
    $javascript->link('scriptaculous/lib/prototype', false);
?>
<?php
endif;
?>
<div class="items form">
<?php echo $ajax->form('Item','post',array('update'=>'myform','url'=>array('action'=>'ajax_form','controller'=>'items','committee'=>$dcommittee['Committee']['short_name']))); ?>
<fieldset id="myform">
<legend><?php echo sprintf(__('Add %s',true),$item_name) ;?></legend>
<script>
<?php
if(isset($saved) && $saved){
    echo "Modalbox.hide({afterHide:reloaditems})";
}
?>
</script>
<?php
echo $form->hidden('Item.committee_id',array('value'=>$dcommittee['Committee']['id']));
echo $form->input('Item.name', array('error'=>__('This field cannot be left blank',true),'size'=>'30','class'=>'required'));

/*
echo $form->input('Item.short_name', array('error'=>array(
    'required'=>__('This field cannot be left blank',true),
    'alphaNumeric'=>__('Alphabets and numbers only',true),
    'unique'=>__('This name already taken in this committee',true)
)));
*/
echo $form->input('Item.short_name');
echo $form->input('Item.description');
echo "<div class='datetime'>";
echo $form->label('Item.startdate',__('Start date',true));
echo "</div>";
echo $form->datetime('startdate','YMD','NONE',date("Y-m-d H:i:s"),array('monthNames'=>false,'separator'=>'-','minYear'=>date('Y')-5,'maxYear'=>date('Y')+5),true);
echo "<div class='datetime'>";
echo $form->label('Item.deadline',__('Deadline',true));
echo "</div>";
$nextmonth=date("Y-m-d H:i:s",mktime(0, 0, 0, date("m")+1, date("d")-1, date("y")));
echo $form->datetime('Item.deadline','YMD','NONE',$nextmonth,array('monthNames'=>false,'separator'=>'-','minYear'=>date('Y')-5,'maxYear'=>date('Y')+5),true);
if(isset($returnpage)){
    echo $form->hidden('returnpage',array('value'=>$returnpage));
}
?>
</fieldset>
<br/>
<?php echo $form->button(__('Save', true),array('type'=>'submit'));?>&nbsp;
<?php echo $form->button(__('Cancel', true), array('type'=>'button', 'onclick'=>'Modalbox.hide()'));?>
<?php echo $form->end();?>
</div>
